package edu.mis.modules.customer;

import java.util.List;

import edu.mis.model.Customer;
import edu.mis.model.User;

public class CustomerService {
	
	//这里是数据库的访问工具
	private Customer dao = new Customer().dao();
	//这里提供一个方法给Controller调用
	
	/**
	 * 根据ID得到用户
	 * @param id
	 * @return
	 */
	public Customer findCustomerById(int id) {
		return Customer.dao.findById(id);
	}
	
	public List<Customer> getAllCustomer(){
		System.out.println("进入了Service。");
		List<Customer> customers = dao.find("select * from customer");
		//将查询结果返回
		return customers;
	}
	
	/**
	 * 修改
	 * @param user
	 * @return
	 */
	public boolean updateAge(int id,int newAge){
		Customer customer = findCustomerById(id);
		customer.setAge(new Integer(newAge));
		return customer.update();
	}

}
